import Vue from "vue";
import VueRouter from "vue-router";
import Router from 'vue-router';

let Home = () => import('../views/home/home.vue');
let Partaker = () => import('../views/partaker/partaker.vue');
let Classify = () => import('../views/classify/classify.vue');
let Shoppingcart = () => import('../views/shoppingcart/shoppingcart.vue');
let Me = () => import('../views/me/me.vue')
let app404 = () => import('../views/404.vue')
let longin = () => import('../views/login.vue')
let reg = () => import('../views/reg.vue')

Vue.use(VueRouter);

const routes = [{
    path: '/home',
    name: '首页',
    component: Home,
  },
  {
    path: '/',
    redirect: '/home',
    component: Home,
  },
  {
    path: "/partaker",
    name: "拼团",
    component: Partaker,
  },

  {
    path: "/classify",
    name: "分类",
    component: Classify,
  },
  {
    path: "/shoppingcart",
    name: "购物车",
    component: Shoppingcart,
  },
  {
    path: "/me",
    name: "我的",
    component: Me,
  },
  {
    path: '/404',
    component: app404,
  },
  {
    path: '/login',
    name: '登陆',
    component: longin
  },
  {
    path: '/reg',
    name: '注册',
    component: reg,
  }
];
// 解决连续点击报错的问题
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
}
const router = new VueRouter({
  routes,
});

export default router;